﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.项目成果管理.service
{
    public class 项目成果Service
    {
        /// <summary>
        /// 根据批号查看工序
        /// </summary>
        /// <returns></returns>
        public static List<DTO查看工序> get查看工序ByBatchNo(String batchNo)
        {
            return
                FunctionHelper.JsonDeserialization<List<DTO查看工序>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/project/getProjectInstanceSimplesByBatchNo?batchNo=" + batchNo
                        )
                    );
        }
        /// <summary>
        /// 获取全部成果项目
        /// </summary>
        /// <returns></returns>
        public static DTO工序管理 get全部工序(String wbsTemplateId)
        {
            return 
                FunctionHelper.JsonDeserialization<DTO工序管理>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/project/findWBSTemplateDByIdAndSaveCache?wbsTemplateId=" + wbsTemplateId
                        )
                    );
        }
        public static void post工序(DTO工序管理 dTO工序管理)
        {
            RestCall.PostHttp(
                    URL.接口url + "/project/saveWBSTemplate",
                    FunctionHelper.JsonSerialization(dTO工序管理)
                );
        }
        /// <summary>
        /// 点击左侧树
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static wbsItemDTO get点击单个项目(String code)
        {
            return
                FunctionHelper.JsonDeserialization<wbsItemDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/project/getWBSItemByCode?code=" + code
                        )
                    );
        }
        /// <summary>
        /// 项目成果管理，完成工作扫描员工信息
        /// </summary>
        public static void  post项目成果提交(DTO项目成果提交 DTO项目成果提交)
        {
            RestCall.PostHttp(
                    URL.接口url + "/project/saveBatchProjectInstance?mnemonic=" + DTO项目成果提交.mnemonic
                        + "&batchNo=" + DTO项目成果提交.batchNo
                            + "&code=" + DTO项目成果提交.code,
                    DTO项目成果提交.content
                    );
        }
        /// <summary>
        /// 编排生产批，项目成果管理，完成工作扫描员工信息
        /// </summary>
        public static String post编排生产批提交(DTO项目成果提交 DTO项目成果提交)
        {
            return 
            RestCall.PostHttp(
                    URL.接口url + "/pmc/saveBatchProjectInstance?mnemonic=" + DTO项目成果提交.mnemonic
                        + "&batchNo=" + DTO项目成果提交.batchNo
                            + "&code=" + DTO项目成果提交.code,
                    DTO项目成果提交.content
                    );
        }
        public static String get判断扫描员工码是否正确(String mnemonic)
        {
            return
                RestCall.httpGetMethod(
                    URL.接口url + "/project/checkMnemonic?mnemonic=" + mnemonic
                    );
        }
        /// <summary>
        /// 创建审版任务分配状况
        /// </summary>
        /// <param name="barcodes"></param>
        /// <returns></returns>
        public static List<审版分活DTO> saveDesignVerify(List<审版分活扫码DTO> batchNos)
        {
            String xx = FunctionHelper.JsonSerialization(batchNos);
            return
                FunctionHelper.JsonDeserialization<List<审版分活DTO>>(
                RestCall.PostHttp(
                URL.接口url + "/process/saveDesignVerify",
                FunctionHelper.JsonSerialization(batchNos)
                )
            );
        }
        /// <summary>
        /// 更新任务分配
        /// </summary>
        /// <param name="batchNos"></param>
        public static void updateDesignJobAssingment(List<审版分活员工DTO> batchNos)
        {
            String xx = FunctionHelper.JsonSerialization(batchNos);
            RestCall.PostHttp(
                URL.接口url + "/process/updateDesignJobAssingment",
                FunctionHelper.JsonSerialization(batchNos)
                );
        }
        /// <summary>
        /// 取审版任务分配状况一览
        /// </summary>
        /// <returns></returns>
        public static List<审版分活DTO> getDesignVerifyAll()
        {
            return
                FunctionHelper.JsonDeserialization<List<审版分活DTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/process/getDesignVerifyAll"
                        )
                    );
        }
    }
    public class 审版分活扫码DTO
    {
        public String batchNo { get; set; }
        public String styleNameCn { get; set; }
        public 审版分活扫码DTO()
        {

        }
        public 审版分活扫码DTO(string batchNo, string styleNameCn)
        {
            this.batchNo = batchNo;
            this.styleNameCn = styleNameCn;
        }
    }
    public class 审版分活员工DTO
    {
        public String batchNo { get; set; }
        public String responsorId { get; set; }
        public String responsor { get; set; }
        public 审版分活员工DTO()
        {

        }

        public 审版分活员工DTO(string batchNo, string responsorId, string responsor)
        {
            this.batchNo = batchNo;
            this.responsorId = responsorId;
            this.responsor = responsor;
        }
    }
    public class 审版分活DTO
    {
        public String batchNo { get; set; }
        public String styleNameCn { get; set; }
        public String responsorId { get; set; }
        public String responsor { get; set; }
        public DateTime startTime { get; set; }
        public Boolean isFinish { get; set; }
        public DateTime finishTime { get; set; }
        public DateTime createDate { get; set; }

        public 审版分活DTO()
        {

        }
        public 审版分活DTO(String batchNo, String styleNameCn,String mnemonic, String workerName)
        {
            this.batchNo = batchNo;
            this.styleNameCn = styleNameCn;
            this.responsorId = mnemonic;
            this.responsor = workerName;
        }
    }
    /// <summary>
    /// 项目成果管理，完成各自任务后扫描员工信息提交工作DTO
    /// </summary>
    public class DTO项目成果提交
    {
        public String mnemonic { get; set; }
        public String batchNo { get; set; }
        public String code { get; set; }
        public String content { get; set; }
        public DTO项目成果提交()
        {

        }

        public DTO项目成果提交(string batchNo, string code, string content)
        {
            this.batchNo = batchNo;
            this.code = code;
            this.content = content;
        }
    }

    public class DTO工序管理
    {
        public String id { get; set; }
        public String templateName { get; set; }
        public List<wbsItemDTO> wbsItemDTOList { get; set; } = new List<wbsItemDTO>();
        public DTO工序管理()
        {

        }

    }

    public class wbsItemDTO  //整个工序管理中的每个工序
    {
        public String id { get; set; }
        public String parentId { get; set; }
        public String activityDescription { get; set; }
        public String code { get; set; }
        public String index { get; set; }
        public List<achievementTemplateDTO> achievementTemplateDTOS { get; set; } = new List<achievementTemplateDTO>();
        public wbsItemDTO()
        {

        }

        public wbsItemDTO(string id, string parentId, string activityDescription, string code, string index)
        {
            this.id = id;
            this.parentId = parentId;
            this.activityDescription = activityDescription;
            this.code = code;
            this.index = index;
        }
    }

    public class achievementTemplateDTO
    {

    }

    public class DTO查看工序
    {
        public String activityDescription { get; set; }
        public DateTime actualFinishDate { get; set; }
        public String batchNo { get; set; }
        public String code { get; set; }
        public Double costPlusFixedFee { get; set; }
        public Double duration { get; set; }
        public String id { get; set; }
        public Double index { get; set; }
        public String orderId { get; set; }
        public String parentId { get; set; }
        public String responsor { get; set; }
        public String responsorId { get; set; }
        public DateTime startTimePlanned { get; set; }
        public String wbsItemId { get; set; }
        public String wbsTemplateId { get; set; }
        public DTO查看工序()
        {

        }
    }

}
